/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 * 
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org/licenses/gpl-3.0.html
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package metaphor.persistence.filter;

import java.io.Serializable;

/**
 *
 * @author Mark Ashworth <javameme@gmail.com>
 * @version 1.0.0
 */
public class Expressions {

    protected Expressions() { } 
    
    /**
	 * The following expresses that the price should be greater or equal to
	 * 100.<br />
	 * <i>SimpleFilter.ge("price", 100);</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression ge(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.GE, operand);
	}
	
	/**
	 * The following expresses that the price should be greater than
	 * 100.<br />
	 * <i>SimpleFilter.gt("price", 100);</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression gt(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.GT, operand);
	}
	
	/**
	 * The following expresses that the price should be less or equal to
	 * 100.<br />
	 * <i>SimpleFilter.le("price", 100);</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression le(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.LE, operand);
	}
	
	/**
	 * The following expresses that the price should be less than
	 * 100.<br />
	 * <i>SimpleFilter.lt("price", 100);</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression lt(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.LT, operand);
	}
	
	/**
	 * The following expresses that the price should be equal to
	 * 100.<br />
	 * <i>SimpleFilter.eq("price", 100);</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression eq(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.EQ, operand);
	}
	
	/**
	 * The following expresses that the name should be like '%JO%'.<br />
	 * <i>SimpleFilter.like("name", "%JO%");</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression like(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.LIKE, operand);
	}
    
    /**
	 * The following expresses that the name should be like '%JO%'.<br />
	 * <i>SimpleFilter.like("name", "%JO%");</i>
	 * 
	 * @param fieldName The name of the field
	 * @param operand The operand value
	 * @return SimpleFilter
	 */
	public static SimpleExpression ilike(String fieldName, Serializable operand) {
		return new SimpleExpression(fieldName, Operator.ILIKE, operand);
	}
}
